package com.example.shop.controller;

import com.example.shop.entity.Logistice;
import com.example.shop.service.LogisticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName LogisticeController
 * @Description TODO
 * @Author 萍
 * @Date 2025/3/26 10:20
 */

@RestController
@RequestMapping("/logistice")
public class LogisticeController {

    @Autowired
    private LogisticeService logisticeService;

    /**
     * 通过ID查询单条数据
     *
     * @param logisticeid 主键
     * @return 实例对象
     */
    @GetMapping("/{logisticeid}")
    public Logistice queryById(@PathVariable Integer logisticeid) {
        return logisticeService.queryById(logisticeid);
    }

    /**
     * 新增数据
     *
     * @param logistice 实例对象
     * @return 实例对象
     */
    @PostMapping
    public Logistice insert(@RequestBody Logistice logistice) {
        return logisticeService.insert(logistice);
    }

    /**
     * 修改数据
     *
     * @param logistice 实例对象
     * @return 实例对象
     */
    @PutMapping
    public Logistice update(@RequestBody Logistice logistice) {
        return logisticeService.update(logistice);
    }

    /**
     * 通过主键删除数据
     *
     * @param logisticeid 主键
     * @return 是否成功
     */
    @DeleteMapping("/{logisticeid}")
    public boolean deleteById(@PathVariable Integer logisticeid) {
        return logisticeService.deleteById(logisticeid);
    }

    // 如果需要查询所有数据，可以添加如下方法
    /**
     * 查询所有数据
     *
     * @return 数据列表
     */
    @GetMapping
    public List<Logistice> queryAll() {
        return logisticeService.queryAll();
    }
}
